package com.geek.bulk.echo;

import org.eclipse.microprofile.faulttolerance.ExecutionContext;
import org.eclipse.microprofile.faulttolerance.FallbackHandler;

import java.lang.reflect.Method;


public class EchoFallBackService extends EchoService implements FallbackHandler<Void>{
  @Override
  public void echo(Long message) {
    System.out.println("fallback = " + "fallback");
  }

  @Override
  public Void handle(ExecutionContext context) {
    Method method = context.getMethod();
    Object[] parameters = context.getParameters();
    try {
      method.invoke(this, parameters);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return null;
  }
}
